//
//  AppGradeMessage.m
//  SulitLoan
//
//  Created by 虞嘉伟 on 2025/3/12.
//  
  

#import "AppGradeMessage.h"
#import <StoreKit/StoreKit.h>

@implementation AppGradeMessage

- (NSString *)name {
    return @"lionBellp";
}
- (instancetype)initWithController:(UIViewController *)controller {
    if (self = [super init]) {
        self.controller = controller;
    }
    return self;
}
- (void)handleMessage:(WKScriptMessage *)message {
    if ([message.name isEqualToString:self.name]) {
        if (@available(iOS 10.3, *)) {
            [SKStoreReviewController requestReview];
        } else {
            // 对于 iOS 10.3 以下的版本，可以使用其他方式引导用户去 App Store 评分
            NSString *appID = @"YOUR_APP_ID";
            NSString *urlStr = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/app/id%@?action=write-review", appID];
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlStr]];
        }
    }
}

@end
